<?php
class ModuleModel extends Db
{
    protected $_news_list = 'w_news_list'; //基本信息
    protected $_news_content = 'w_news_content'; //文章
    protected $_news_image = 'w_news_image'; //图集
    protected $_news_special = 'w_news_special'; //专题
    //查找基本信息
    public function getModuleBase ($where, $limit)
    {
        return $this->getAll($this->_news_list, $where, null, null, $limit);
    }
    //添加模型基本信息
    public function addModuleBase ($params)
    {
        $this->add($this->_news_list, $params);
        return $this->lastInsertId();
    }
    //添加模型内容
    public function addModuleCon ($params, $type = 1)
    {
        switch ($type) {
            case 1:
                $lastInsertId = $this->add($this->_news_content, $params);
                break;
            case 2:
                $lastInsertId = $this->add($this->_news_image, $params);
                break;
            case 3:
                $lastInsertId = $this->add($this->_news_special, $params);
                break;
        }
    }
    //返回模型内容
    public function getModuleCon ($where, $type = 1)
    {
        switch ($type) {
            case 1:
                $rs = $this->getAll($this->_news_content, $where);
                break;
            case 2:
                $rs = $this->getAll($this->_news_image, $where, null, 
                'weight ASC');
                break;
            case 3:
                $rs = $this->getAll($this->_news_special, $where);
                break;
        }
        return $rs;
    }
    //返回模型内容
    public function saveModuleCon ($v, $where, $type = 1)
    {
        switch ($type) {
            case 1:
                $rs = $this->update($this->_news_content, $v, $where);
                break;
            case 2:
                $rs = $this->update($this->_news_image, $v, $where);
                break;
            case 3:
                $rs = $this->update($this->_news_special, $v, $where);
                break;
        }
        return $rs;
    }
    public function removeModuleCon ($where, $type = 1)
    {
        switch ($type) {
            case 1:
                $rs = $this->delete($this->_news_content, $where);
                break;
            case 2:
                $rs = $this->delete($this->_news_image, $where);
                break;
            case 3:
                $rs = $this->delete($this->_news_special, $where);
                break;
        }
        return $rs;
    }
    /**
     * 返回ModuleModel
     * @return ModuleModel
     */
    public static function instance ()
    {
        return parent::_instance(__CLASS__);
    }
}